package com.yazi.mxz.job.common.tool;

import javax.mail.MessagingException;
import javax.mail.internet.AddressException;

import com.yazi.mxz.job.common.MySetting;

public class EmailFactory {
	private static boolean isConfig = false;
	public static void config() throws MessagingException {
		// 发件邮箱服务器
		Email.config(
				MySetting.getMailHost(), 
				MySetting.getMailName(), 
				MySetting.getMailAddress(),
				MySetting.getMailPwd(), 
				true);
		isConfig = true;
	}

	public static void sendMail(String toAddress, String subject, String content)
			throws AddressException, MessagingException {
		if (!isConfig) config();
		// 收件人
		Email.setEmails(toAddress);
		// 发件
		Email.send(subject, content);
	}

}
